<template>
	<div>好友列表</div>
</template>
<script>
export default {
	name: "friendList",
	data() {
        return {
            friendList: "",
		};
	},
    mounted() {
        this.requireAllUser()
    },
	methods: {
		/**
		 * 配置好友请求
		 */
		listConfig(userId) {
			return [];
			this.friendList.forEach((element) => {
				return [];
			});
			return this.$axios({
				url: "/users/inquireFriendList",
				method: "post",
				data: {
					userId: userId,
					inquire: "friendInfo",
				},
			})
				.then((res) => {
					console.log(res);
				})
				.catch((err) => {
					console.log(err);
				});
		},

		/**
		 * 请求好友列表
		 */
		inquireFriendList() {
			let userId = JSON.parse(localStorage.getItem("chatUser")).userId;
			let listConfigIndex = 0;
			this.$axios({
				url: "/users/inquireFriendList",
				method: "post",
				data: {
					userId: userId,
					inquire: "friendList",
				},
			}).then((res) => {
				this.friendList = res.data.data.split(",");
				this.$axios.all([...listConfig(this.friendList[0])]).then(
					this.$axios.spread((allRes1, allRes2) => {
						console.log(allRes1);
						console.log(allRes2);
					})
				);
			});
		},

		//查询所有用户信息
		requireAllUser() {
			this.$axios({
				method: "post",
				url: "/users/inquireFriendList",
				data: {
					admin: "1",
					inquire: "friendList",
				},
			})
				.then((res) => {
					console.log("res: ", res);
				})
				.catch((err) => {
					console.log("err: ", err);
				});
		},
	},
};
</script>